package com.fxsh168.server.activity;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.util.Log;
import android.widget.TextView;

import com.fxsh168.server.base.BaseActivity;
import com.fxsh168.server.entitys.AboutUsEntity;
import com.fxsh168.server.interfaces.Constant;
import com.fxsh168.server.R;
import com.fxsh168.server.utils.upapp.UpdateApp;
import com.google.gson.Gson;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;

import okhttp3.Call;

public class AboutUsActivity extends BaseActivity {

    private TextView mCuurentVerson;
     String token, mPhone ;
    TextView te_about;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about_us);
        mCuurentVerson = (TextView) findViewById(R.id.cuurentVerson);//版本号
        te_about = (TextView) findViewById(R.id.te_about);
        SharedPreferences sp = getSharedPreferences(Constant.LOGINCLASS, MODE_PRIVATE);
        mPhone = sp.getString("mPhone", "");
        token = sp.getString("token", "");
        String versionCode = UpdateApp.getVersionName(AboutUsActivity.this);
        Log.e("6666666",versionCode);
        mCuurentVerson.setText("V" + versionCode);
        getAboutUs();
    }

    //    获取关于我们的文本
    public void getAboutUs() {
        OkHttpUtils.get().url(Constant.ABOUTSTRING).build().execute(new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
                showToast("网络链接失败");
            }

            @Override
            public void onResponse(String response, int id) {
                Log.e("tag", "获取到的" + response);
                AboutUsEntity aboutUsEntity = new Gson().fromJson(response, AboutUsEntity.class);
                String code = aboutUsEntity.getCode();
                if (code.equals("200")) {
                    String driver_about = aboutUsEntity.getData().get(0).getDriver_about();
                    te_about.setText(driver_about);
                }
            }
        });
    }

}
